package sk.gtug.pivoplus.malepivo.map;

import sk.gtug.pivoplus.malepivo.R;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.RatingBar;
import android.widget.TextView;

import com.google.android.maps.OverlayItem;
import com.readystatesoftware.mapviewballoons.BalloonOverlayView;

public class PubBalloonOverlayView<Item extends OverlayItem> extends BalloonOverlayView<PubOverlayItem> {

	private TextView mTitle;
	//private TextView mSnippet;
	private RatingBar mRating;

	public PubBalloonOverlayView(Context context, int balloonBottomOffset) {
		super(context, balloonBottomOffset);
	}

	@Override
	protected void setupView(Context context, final ViewGroup parent) {
		View v = LayoutInflater.from(context).inflate(R.layout.custom_balloon_overlay, parent);
		mTitle = (TextView) v.findViewById(R.id.balloon_item_title);
		//mSnippet = (TextView) v.findViewById(R.id.balloon_item_snippet);
		mRating = (RatingBar) v.findViewById(R.id.balloon_item_rating);
	}

	@Override
	protected void setBalloonData(PubOverlayItem item, ViewGroup parent) {
		mTitle.setText(item.getTitle());
		//mSnippet.setText(item.getSnippet());
		//TODO isNaN, zero, null...
		mRating.setRating(item.geRating());
		// NOTE: kedze pouzivam rozne markers, je treba nastavit spravny offset jednotlivo
		if (item.getMarker(0) != null) {
			setPadding(10, 0, 10, item.getMarker(0).getIntrinsicHeight());
		}
	}
}
